<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <%@include file="../common.jsp"%>

    <title>流浪猫狗认养系统</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        html {
            background: url("/web/images/loginbg1.jpg");
            height: 100%;
        }
        body {
            background: transparent;
        }
        .login-container {
            width: 600px;
            height: 315px;
            margin: 0 auto;
            margin-top: 10%;
            border-radius: 15px;
            box-shadow: 0 10px 50px 0px #423834;
            background-color: #63534d;
            opacity: 0.6;

        }
        .left-container {
            display: inline-block;
            width: 330px;
            border-top-left-radius: 15px;
            border-bottom-left-radius: 15px;
            padding: 60px;
            background-image: linear-gradient(to bottom right, #423834, #423834);
        }
        .title {
            color: #fff;
            font-size: 18px;
            font-weight: 200;
        }
        .title span {
            border-bottom: 3px solid rgb(237, 221, 22);
        }
        .input-container {
            padding: 20px 0;
            background-color: transparent;
            border: 0;
        }
        input {
            border: 0;
            /*background: none;*/
            background-color: transparent;
            outline: none;
            color: #fff;
            margin: 20px 0;
            display: block;
            width: 100%;
            padding: 5px 0;
            transition: .2s;
            border-bottom: 1px solid rgb(199, 191, 219);
        }
        input:hover {
            border-bottom-color: #fff;
        }
        ::-webkit-input-placeholder {
            color: rgb(199, 191, 219);
        }
        .message-container {
            font-size: 14px;
            transition: .2s;
            color: rgb(199, 191, 219);
            cursor: pointer;
        }
        .message-container:hover {
            color: #fff;
        }
        .right-container {
            width: 145px;
            display: inline-block;
            height: calc(100% - 120px);
            vertical-align: top;
            padding: 60px 0;
        }
        .regist-container {
            text-align: center;
            color: #fff;
            font-size: 18px;
            font-weight: 200;
            cursor: pointer;
        }
        .regist-container span {
            border-bottom: 3px solid rgb(237, 221, 22);
        }
        .action-container {
            font-size: 10px;
            color: #fff;
            text-align: center;
            position: relative;
            top: 200px;
        }
        .action-container span {
            border: 1px solid rgb(237, 221, 22);
            padding: 10px;
            display: inline;
            line-height: 20px;
            border-radius: 20px;
            position: absolute;
            bottom: 10px;
            left: calc(72px - 20px);
            transition: .2s;
            cursor: pointer;
        }
        .action-container span:hover {
            background-color: rgb(237, 221, 22);
            color: rgb(95, 76, 194);
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="left-container">
        <div class="title"><span>欢迎你，新用户</span></div>
        <div class="input-container">
            <input id="username" type="text" name="username" placeholder="请输入注册账号">
            <input id="password" type="password" name="password" placeholder="请输入注册密码">
        </div>
        <div class="message-container">
            <span onclick="toLogin()">返回登录页</span>
        </div>
    </div>
    <div class="right-container">
        <div class="regist-container">
<%--            <span class="regist" onclick="regist()">注册</span>--%>
        </div>
        <div class="action-container">
            <span onclick="regist()">提交</span>
        </div>
    </div>
</div>

<script>

    function regist(){
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        if('' !== username && '' !== password){
            $.ajax({
                "url": base_url + "user/addUser.do",
                "data": {
                    'username':username
                    ,'password':password
                },
                "method": "post",
                success: function (e) {
                    console.log(e);
                    if(e.code === "0"){
                        layer.alert("注册成功",function (){
                            window.location= '../../../web/pages/front/userlogin.jsp';
                        });
                        // window.location = base_url+'/user/afterLogin.do'+ "?id=" + e.data.id;
                    }else{
                        layer.alert("注册失败");
                    }
                },
                error: function () {
                    layer.alert("出错了，请联系管理员");
                }
            });
            return false;
        }else{
            if(username === '' ){
                layer.alert("用户名不能为空");
            }
            if(password === ''){
                layer.alert("密码不能为空");
            }
        }
    }
    function toLogin(){
        window.location =  '../../../web/pages/front/userlogin.jsp'
    }

</script>
</body>
</html>
